<?php
	class Diklat_model extends Model{
		function Diklat_model(){
			parent::Model();
		}
        
        function list_diklat_struktural($nip="", $where="", $order="", $ro=false) {
               
        	if ($nip=="") {
        		return "";
        	} else {
                $this->db->where(array('nip' => $nip));
                $this->db->or_where(array('nip_baru' => $nip));
        	}
            $this->db->from('pegawai');
            $q = $this->db->get();
			
            $s = "
              <table  width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" class=\"tbl\">
                <thead>
                  <tr>
                    <th>No</th>
                    <!--<th>Kategori</th>-->
                    <th>Nama Diklat</th>
                    <th>Tanggal</th>
                    <th>Penyelenggara/Tempat</th>
                    <th>Jumlah Jam</th>
                    <th>Nomor STTP</th>
                    <th>Tanggal STTP</th>
                    ";
            if ($ro==false) {
                $s .= " <th colspan='2'> Aksi </th>";
            }
            $s .= "</tr></thead><tbody>";
			$i = 1;

            $this->load->model('Datum_model');
            foreach($q->result() as $row) {
                if ($i % 2 == 1) {
                    $kelas = "event2";
                } else {
                    $kelas = "event";
                }

                //data history jabatan
                $this->db->select('diklat.idspg_diklat as id, '.
                                  'diklat.nama as nama, diklat.tempat as tempat, '.
                				  'diklat.tgl_mulai as tgl_mulai, diklat.tgl_selesai as tgl_selesai, '.
                				  'diklat.total_jam as total_jam, '.
                                  'diklat.tgl_sttp as tgl_sttp, diklat.no_sttp as no_sttp, '.
                				  'diklat.id_jenis_diklat_struktural as id_jenis_diklat_struktural, '
                				  );
                $this->db->from('diklat');
                //$this->db->join('jenis_diklat_struktural', 'jenis_diklat_struktural.idspg_jenis_diklat_struktural=diklat.id_jenis_diklat_struktural');
                //$this->db->join('kategori_diklat_struktural', 'kategori_diklat_struktural.idspg_kategori_diklat_struktural=jenis_diklat_struktural.id_kategori_diklat_struktural');
                $this->db->where(array('diklat.id_pegawai' => $row->idspg_pegawai));
                $this->db->where(array('diklat.id_jenis_diklat' => TIPE_DIKLAT_STRUKTURAL));
                $this->db->order_by('diklat.tgl_mulai asc');
                $q1 = $this->db->get();
				//return $this->db->last_query();
                if ($q1->num_rows() > 0) {
                	foreach ($q1->result() as $row1) {
		                $id_jenis_diklat = Datum_model::getData('id_kategori_diklat_struktural', 'jenis_diklat_struktural', array('idspg_jenis_diklat_struktural' => $row1->id_jenis_diklat_struktural)); 
		                $kategori_diklat = Datum_model::getData('nama', 'kategori_diklat_struktural', array('idspg_kategori_diklat_struktural' => $id_jenis_diklat)); 
		                $nama_diklat_struktural = Datum_model::getData('nama', 'jenis_diklat_struktural', array('idspg_jenis_diklat_struktural' => $row1->id_jenis_diklat_struktural)); 
		                
		                $s .= "
		              <tr class=\"$kelas\" id=\"row-".$row1->id."\" >
		                <td><div align=\"right\">$i.&nbsp;&nbsp;&nbsp;</div></td>
		               <!-- <td>".$kategori_diklat."</td> -->
		                <td>".$row1->nama."</td>
		                <td><div align=center>".YMD2DMY(trimTime($row1->tgl_mulai), TGL_SEPARATOR).' s/d '.YMD2DMY(trimTime($row1->tgl_selesai), TGL_SEPARATOR)."</div></td>
		                <td>".$row1->tempat."</td>
		                <td><div align=center>".$row1->total_jam." jam</div></td>
		                <td><div align=center>".$row1->no_sttp."</div></td>
		                <td><div align=center>".YMD2DMY(trimTime($row1->tgl_sttp), TGL_SEPARATOR)."</div></td>
		                ";
		                if ($ro==false) {
		                    $s .= "
		                    <td><div align='center'> <a href='".base_url()."index.php/diklat/form_edit_struktural/".$row1->id."' title=\"Ubah Data\" class=\"edit\"><img src='".base_url()."images/edit.gif' border='0'></a></div></td>";
                            //if($this->input->post('page'))  
		                    $s .="<td><div align='center'><a href=\"javascript:deleteRow(".$row1->id.")\"><img src='".base_url()."images/del.gif' border='0'></a></div></td>";
		                }
		                $s .= "
		              </tr>";
		
		                $i++;
                	}
                }
            }
            $s .= "</tbody></table>";
            return $s;
        }

        
        function list_diklat_teknis($nip="", $where="", $order="", $ro=false) {
        	if ($nip=="") {
        		return "";
        	} else {
                $this->db->where(array('nip' => $nip));
                $this->db->or_where(array('nip_baru' => $nip));
        	}
            $this->db->from('pegawai');
            $q = $this->db->get();

            $s = "
              <table  width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" class=\"tbl\">
                <thead>
                  <tr>
                    <th>No</th>
                   
                    <th>Nama Diklat</th>
                    <th>Penyelenggara/Tempat</th>
                    <th>Angkatan/Tahun</th>
                    <th>Lama Pendidikan</th>
                    <th>Nomor STTP</th>
                    <th>Tanggal STTP</th>
                    ";
            if ($ro==false) {
                $s .= " <th colspan='2'> Aksi </th>";
            }
            $s .= "</tr></thead><tbody>";
			$i = 1;

            $this->load->model('Datum_model');
            foreach($q->result() as $row) {
                if ($i % 2 == 1) {
                    $kelas = "event2";
                } else {
                    $kelas = "event";
                }

                //data history jabatan
                $this->db->select('diklat.idspg_diklat as id, '.
                                  'diklat.nama as nama, diklat.tempat as tempat, '.
                				  'diklat.id_jenis_diklat as id_jenis_diklat, '.
                				  'diklat.angkatan as angkatan, diklat.tahun as tahun, '.
                				  'diklat.lama_pendidikan as lama_pendidikan, '.
                                  'diklat.tgl_sttp as tgl_sttp, diklat.no_sttp as no_sttp ');
                $this->db->from('diklat');
                $this->db->where(array('diklat.id_pegawai' => $row->idspg_pegawai));
                $this->db->where(array('diklat.id_jenis_diklat = ' => TIPE_DIKLAT_TEKNIS));
                $this->db->order_by('diklat.id_jenis_diklat asc');
                $this->db->order_by('diklat.tahun asc');
                $this->db->order_by('diklat.tgl_sttp asc');
                $q1 = $this->db->get();
                if ($q1->num_rows() > 0) {
                	foreach ($q1->result() as $row1) {
		                $s .= "
		              <tr class=\"$kelas\" id=\"row-".$row1->id."\" >
		                <td><div align=\"right\">$i.&nbsp;&nbsp;&nbsp;</div></td>
		                
		                <td>".$row1->nama."</td>
		                <td>".$row1->tempat."</td>
		                <td><div align=center>".$row1->angkatan.'/'.$row1->tahun."</div></td>
		                <td><div align=center>".$row1->lama_pendidikan."</div></td>  
		                <td>".$row1->no_sttp."</td>  
		                <td><div align=center>".YMD2DMY(trimTime($row1->tgl_sttp), TGL_SEPARATOR)."</div></td>
		                ";
		                if ($ro==false) {
		                    $s .= "
		                    <td><div align='center'> <a href='".base_url()."index.php/diklat/form_edit_teknis/".$row1->id."' title=\"Ubah Data\" class=\"edit\"><img src='".base_url()."images/edit.gif' border='0'></a></div></td>   
		                    <td><div align='center'><a href=\"javascript:deleteRow(".$row1->id.")\"><img src='".base_url()."images/del.gif' border='0'></a></div></td>";
		                }
		                $s .= "
		              </tr>";
		
		                $i++;
                	}
                }
            }
            $s .= "</tbody></table>";
            return $s;
        }

        
        
        function list_diklat_fungsional($nip="", $where="", $order="", $ro=false) {
               
        	if ($nip=="") {
        		return "";
        	} else {
                $this->db->where(array('nip' => $nip));
                $this->db->or_where(array('nip_baru' => $nip));
        	}
            $this->db->from('pegawai');
            $q = $this->db->get();
			
            $s = "
              <table  width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" class=\"tbl\">
                <thead>
                  <tr>
                    <th>No</th>
                    <!--<th>Kategori</th>-->
                    <th>Nama Diklat</th>
                    <th>Tanggal</th>
                    <th>Penyelenggara/Tempat</th>
                    <th>Jumlah Jam</th>
                    <th>Nomor STTP</th>
                    <th>Tanggal STTP</th>
                    ";
            if ($ro==false) {
                $s .= " <th colspan='2'> Aksi </th>";
            }
            $s .= "</tr></thead><tbody>";
			$i = 1;

            $this->load->model('Datum_model');
            foreach($q->result() as $row) {
                if ($i % 2 == 1) {
                    $kelas = "event2";
                } else {
                    $kelas = "event";
                }

                //data history jabatan
                $this->db->select('diklat.idspg_diklat as id, '.
                                  'diklat.nama as nama, diklat.tempat as tempat, '.
                				  'diklat.tgl_mulai as tgl_mulai, diklat.tgl_selesai as tgl_selesai, '.
                				  'diklat.total_jam as total_jam, '.
                                  'diklat.tgl_sttp as tgl_sttp, diklat.no_sttp as no_sttp, '                				  
                				  );
                $this->db->from('diklat');               
                $this->db->where(array('diklat.id_pegawai' => $row->idspg_pegawai));
                $this->db->where(array('diklat.id_jenis_diklat' => TIPE_DIKLAT_FUNGSIONAL));
                $this->db->order_by('diklat.tgl_mulai asc');
                $q1 = $this->db->get();
				//return $this->db->last_query();
                if ($q1->num_rows() > 0) {
                	foreach ($q1->result() as $row1) {
		               
		                $s .= "
		              <tr class=\"$kelas\" id=\"row-".$row1->id."\" >
		                <td><div align=\"right\">$i.&nbsp;&nbsp;&nbsp;</div></td>
		               
		                <td>".$row1->nama."</td>
		                <td><div align=center>".YMD2DMY(trimTime($row1->tgl_mulai), TGL_SEPARATOR).' s/d '.YMD2DMY(trimTime($row1->tgl_selesai), TGL_SEPARATOR)."</div></td>
		                <td>".$row1->tempat."</td>
		                <td><div align=center>".$row1->total_jam." jam</div></td>
		                <td><div align=center>".$row1->no_sttp."</div></td>
		                <td><div align=center>".YMD2DMY(trimTime($row1->tgl_sttp), TGL_SEPARATOR)."</div></td>
		                ";
		                if ($ro==false) {
		                    $s .= "
		                    <td><div align='center'> <a href='".base_url()."index.php/diklat/form_edit_fungsional/".$row1->id."' title=\"Ubah Data\" class=\"edit\"><img src='".base_url()."images/edit.gif' border='0'></a></div></td>";
                            //if($this->input->post('page'))  
		                    $s .="<td><div align='center'><a href=\"javascript:deleteRow(".$row1->id.")\"><img src='".base_url()."images/del.gif' border='0'></a></div></td>";
		                }
		                $s .= "
		              </tr>";
		
		                $i++;
                	}
                }
            }
            $s .= "</tbody></table>";
            return $s;
        }

        function entry_diklat_teknis($form_id, $form_action, $arr=array()) {
        	//format tanggal harus YMD
        	if (isset($arr['tgl_mulai'])) {
        		$a = explode(TGL_SEPARATOR, trimTime($arr['tgl_mulai']));
	        	$d_tgl_mulai = $a[2] * 1;
	        	$m_tgl_mulai = $a[1] * 1;
	        	$y_tgl_mulai = $a[0];
        	} else {
	        	$d_tgl_mulai = date("j");
	        	$m_tgl_mulai = date("n");
	        	$y_tgl_mulai = date("Y");
        	}
        	if (isset($arr['tgl_selesai'])) {
        		$a = explode(TGL_SEPARATOR, trimTime($arr['tgl_selesai']));
	        	$d_tgl_selesai = $a[2] * 1;
	        	$m_tgl_selesai = $a[1] * 1;
	        	$y_tgl_selesai = $a[0];
        	} else {
	        	$d_tgl_selesai = date("j");
	        	$m_tgl_selesai = date("n");
	        	$y_tgl_selesai = date("Y");
        	}
        	if (isset($arr['tgl_sttp'])) {
        		$a = explode(TGL_SEPARATOR, trimTime($arr['tgl_sttp']));
	        	$d_tgl_sttp = $a[2] * 1;
	        	$m_tgl_sttp = $a[1] * 1;
	        	$y_tgl_sttp = $a[0];
        	} else {
	        	$d_tgl_sttp = date("j");
	        	$m_tgl_sttp = date("n");
	        	$y_tgl_sttp = date("Y");
        	}
        	
        	$ret = "
			<form id=\"".$form_id."\" action=\"".$form_action."\" method=\"post\">
			<fieldset >
			<table class=\"formTabel\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\">
			  <tr>
			    <td class=\"kolom\" valign=\"top\">NIP</td>
			    <td valign=\"top\">:</td>
			    <td valign=\"top\"><input type=\"text\" name=\"nip\" id=\"nip\" value=\"".(isset($arr['nip'])?$arr['nip']:$this->session->userdata('nip'))."\" /></td>
			  </tr>
			  <tr>
                <td class=\"kolom\" valign=\"top\">Nama Diklat</td>
                <td valign=\"top\">:</td>
                <td valign=\"top\"><input type=\"text\" size=\"38\" name=\"nama\" id=\"nama\" value=\"".(isset($arr['nama'])?$arr['nama']:"")."\" /></td>
              </tr>
			  <tr>
              	<td class='fieldname' valign=\"top\">Tanggal Mulai</td>
		        <td valign=\"top\">:</td>
		        <td>".combo_tanggal('d_tgl_mulai',$d_tgl_mulai,'')."-".
        	          combo_bulan('m_tgl_mulai',$m_tgl_mulai,'').
        	          "-<input name='y_tgl_mulai' id='y_tgl_mulai' type='text' size='6' value='$y_tgl_mulai'/>
        		</td>
    		  </tr>
			  <tr>
              	<td class='fieldname' valign=\"top\">Tanggal Selesai</td>
		        <td valign=\"top\">:</td>
		        <td>".combo_tanggal('d_tgl_selesai',$d_tgl_selesai,'')."-".
        	          combo_bulan('m_tgl_selesai',$m_tgl_selesai,'').
        	          "-<input name='y_tgl_selesai' id='y_tgl_selesai' type='text' size='6' value='$y_tgl_selesai'/>
        		</td>
    		  </tr>
    		  <tr>
			    <td class=\"kolom\" valign=\"top\">Penyelenggara/Tempat</td>
			    <td valign=\"top\">:</td>
			    <td valign=\"top\"><input type=\"text\" size=\"38\" name=\"tempat\" id=\"tempat\" value=\"".(isset($arr['tempat'])?$arr['tempat']:"")."\" /></td>
			  </tr>
			  <tr>
			    <td class=\"kolom\" valign=\"top\">Jumlah Jam</td>
			    <td valign=\"top\">:</td>
			    <td valign=\"top\"><input type=\"text\" size=\"10\" name=\"total_jam\" id=\"total_jam\" value=\"0".(isset($arr['total_jam'])?$arr['total_jam']:"")."\" /> jam</td>
			  </tr>
			  <tr>
			    <td class=\"kolom\" valign=\"top\">Nomor STTP</td>
			    <td valign=\"top\">:</td>
			    <td valign=\"top\"><input type=\"text\" size=\"38\" name=\"no_sttp\" id=\"no_sttp\" value=\"".(isset($arr['no_sttp'])?$arr['no_sttp']:"")."\" /></td>
			  </tr>
			  <tr>
              	<td class='fieldname' valign=\"top\">Tanggal STTP</td>
		        <td valign=\"top\">:</td>
		        <td>".combo_tanggal('d_tgl_sttp',$d_tgl_sttp,'')."-".
        	          combo_bulan('m_tgl_sttp',$m_tgl_sttp,'').
        	          "-<input name='y_tgl_sttp' id='y_tgl_sttp' type='text' size='6' value='$y_tgl_sttp'/>
        		</td>
    		  </tr>
			  <tr>
			    <td valign=\"top\">&nbsp;</td>
			    <td valign=\"top\">&nbsp;</td>
			    <td valign=\"top\">
			      <input class=\"tombol\" type=\"button\" name=\"btn_kembali\" id=\"btn_kembali\" value=\"<< Kembali\" />
			      <input class=\"tombol\" type=\"submit\" name=\"button\" id=\"button\" value=\"   Simpan   \" />
			    </td>
			  </tr>
			</table>
			</fieldset>
			</form>
			  ";
        	
        	return $ret;
        }

        function entry_diklat_fungsional($form_id, $form_action, $arr=array()) {
            //format tanggal harus YMD
            if (isset($arr['tgl_sttp'])) {
                $a = explode(TGL_SEPARATOR, trimTime($arr['tgl_sttp']));
                $d_tgl_sttp = $a[2] * 1;
                $m_tgl_sttp = $a[1] * 1;
                $y_tgl_sttp = $a[0];
            } else {
                $d_tgl_sttp = date("j");
                $m_tgl_sttp = date("n");
                $y_tgl_sttp = date("Y");
            }
            
            $ret = "
            <form id=\"".$form_id."\" action=\"".$form_action."\" method=\"post\">
            <fieldset >
            <table class=\"formTabel\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\">
              <tr>
                <td class=\"kolom\" valign=\"top\">NIP</td>
                <td valign=\"top\">:</td>
                <td valign=\"top\"><input type=\"text\" name=\"nip\" id=\"nip\" value=\"".(isset($arr['nip'])?$arr['nip']:$this->session->userdata('nip'))."\" /></td>
              </tr>
              
              <tr>
                <td class=\"kolom\" valign=\"top\">Nama Diklat</td>
                <td valign=\"top\">:</td>
                <td valign=\"top\"><input type=\"text\" size=\"38\" name=\"nama\" id=\"nama\" value=\"".(isset($arr['nama'])?$arr['nama']:"")."\" /></td>
              </tr>
			  <tr>
              	<td class='fieldname' valign=\"top\">Tanggal Mulai</td>
		        <td valign=\"top\">:</td>
		        <td>".combo_tanggal('d_tgl_mulai',$d_tgl_mulai,'')."-".
        	          combo_bulan('m_tgl_mulai',$m_tgl_mulai,'').
        	          "-<input name='y_tgl_mulai' id='y_tgl_mulai' type='text' size='6' value='$y_tgl_mulai'/>
        		</td>
    		  </tr>
			  <tr>
              	<td class='fieldname' valign=\"top\">Tanggal Selesai</td>
		        <td valign=\"top\">:</td>
		        <td>".combo_tanggal('d_tgl_selesai',$d_tgl_selesai,'')."-".
        	          combo_bulan('m_tgl_selesai',$m_tgl_selesai,'').
        	          "-<input name='y_tgl_selesai' id='y_tgl_selesai' type='text' size='6' value='$y_tgl_selesai'/>
        		</td>
    		  </tr>
              <tr>
                <td class=\"kolom\" valign=\"top\">Penyelenggara/Tempat</td>
                <td valign=\"top\">:</td>
                <td valign=\"top\"><input type=\"text\" size=\"38\" name=\"tempat\" id=\"tempat\" value=\"".(isset($arr['tempat'])?$arr['tempat']:"")."\" /></td>
              </tr>
              <tr>
                <td class=\"kolom\" valign=\"top\">Angkatan</td>
                <td valign=\"top\">:</td>
                <td valign=\"top\"><input type=\"text\" size=\"6\" name=\"angkatan\" id=\"angkatan\" value=\"".(isset($arr['angkatan'])?$arr['angkatan']:"")."\" /></td>
              </tr>
              <tr>
                <td class=\"kolom\" valign=\"top\">Tahun</td>
                <td valign=\"top\">:</td>
                <td valign=\"top\"><input type=\"text\" name=\"tahun\" id=\"tahun\" size=\"6\" value=\"".(isset($arr['tahun'])?$arr['tahun']:"")."\" /></td>
              </tr>
              <tr>
                <td class=\"kolom\" valign=\"top\">Lama Pendidikan</td>
                <td valign=\"top\">:</td>
                <td valign=\"top\"><input type=\"text\" size=\"38\" name=\"lama_pendidikan\" id=\"lama_pendidikan\" value=\"".(isset($arr['lama_pendidikan'])?$arr['lama_pendidikan']:"")."\" /></td>
              </tr>
              <tr>
                <td class=\"kolom\" valign=\"top\">Nomor STTP</td>
                <td valign=\"top\">:</td>
                <td valign=\"top\"><input type=\"text\" size=\"38\" name=\"no_sttp\" id=\"no_sttp\" value=\"".(isset($arr['no_sttp'])?$arr['no_sttp']:"")."\" /></td>
              </tr>
              <tr>
                  <td class='fieldname' valign=\"top\">Tanggal STTP</td>
                <td valign=\"top\">:</td>
                <td>".combo_tanggal('d_tgl_sttp',$d_tgl_sttp,'')."-".
                      combo_bulan('m_tgl_sttp',$m_tgl_sttp,'').
                      "-<input name='y_tgl_sttp' id='y_tgl_sttp' type='text' size='6' value='$y_tgl_sttp'/>
                </td>
              </tr>
              <tr>
                <td valign=\"top\">&nbsp;</td>
                <td valign=\"top\">&nbsp;</td>
                <td valign=\"top\">
                  <input class=\"tombol\" type=\"button\" name=\"btn_kembali\" id=\"btn_kembali\" value=\"<< Kembali\" />
                  <input class=\"tombol\" type=\"submit\" name=\"button\" id=\"button\" value=\"   Simpan   \" />
                </td>
              </tr>
            </table>
            </fieldset>
            </form>
              ";
            
            return $ret;
        }
        
        function entry_diklat_struktural($form_id, $form_action, $arr=array()) {
        	//format tanggal harus YMD
        	if (isset($arr['tgl_sttp'])) {
        		$a = explode(TGL_SEPARATOR, trimTime($arr['tgl_sttp']));
	        	$d_tgl_sttp = $a[2] * 1;
	        	$m_tgl_sttp = $a[1] * 1;
	        	$y_tgl_sttp = $a[0];
        	} else {
	        	$d_tgl_sttp = date("j");
	        	$m_tgl_sttp = date("n");
	        	$y_tgl_sttp = date("Y");
        	}
        	
        	$ret = "
			<form id=\"".$form_id."\" action=\"".$form_action."\" method=\"post\">
			<fieldset >
			<table class=\"formTabel\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\">
			  <tr>
			    <td class=\"kolom\" valign=\"top\">NIP</td>
			    <td valign=\"top\">:</td>
			    <td valign=\"top\"><input type=\"text\" name=\"nip\" id=\"nip\" value=\"".(isset($arr['nip'])?$arr['nip']:$this->session->userdata('nip'))."\" /></td>
			  </tr>
			 <!-- <tr>
			    <td class=\"kolom\" valign=\"top\">Kategori Diklat</td>
			    <td valign=\"top\">:</td>
			    <td valign=\"top\">".combo_kategori_diklat_struktural('id_jenis_diklat', (isset($arr['id_jenis_diklat'])?$arr['id_jenis_diklat']:""))."</td>
			  </tr>
			  -->
			  <tr>
			    <td class=\"kolom\" valign=\"top\">Nama Diklat</td>
			    <td valign=\"top\">:</td>
			    <td valign=\"top\"><input type=\"text\" size=\"38\" name=\"nama\" id=\"nama\" value=\"".(isset($arr['nama'])?$arr['nama']:"")."\" /></td>
			  </tr>
    		  <tr>
			    <td class=\"kolom\" valign=\"top\">Penyelenggara/Tempat</td>
			    <td valign=\"top\">:</td>
			    <td valign=\"top\"><input type=\"text\" size=\"38\" name=\"tempat\" id=\"tempat\" value=\"".(isset($arr['tempat'])?$arr['tempat']:"")."\" /></td>
			  </tr>
			  <tr>
			    <td class=\"kolom\" valign=\"top\">Angkatan</td>
			    <td valign=\"top\">:</td>
			    <td valign=\"top\"><input type=\"text\" size=\"6\" name=\"angkatan\" id=\"angkatan\" value=\"".(isset($arr['angkatan'])?$arr['angkatan']:"")."\" /></td>
			  </tr>
			  <tr>
			    <td class=\"kolom\" valign=\"top\">Tahun</td>
			    <td valign=\"top\">:</td>
			    <td valign=\"top\"><input type=\"text\" name=\"tahun\" id=\"tahun\" size=\"6\" value=\"".(isset($arr['tahun'])?$arr['tahun']:"")."\" /></td>
			  </tr>
			  <tr>
			    <td class=\"kolom\" valign=\"top\">Lama Pendidikan</td>
			    <td valign=\"top\">:</td>
			    <td valign=\"top\"><input type=\"text\" size=\"38\" name=\"lama_pendidikan\" id=\"lama_pendidikan\" value=\"".(isset($arr['lama_pendidikan'])?$arr['lama_pendidikan']:"")."\" /></td>
			  </tr>
			  <tr>
			    <td class=\"kolom\" valign=\"top\">Nomor STTP</td>
			    <td valign=\"top\">:</td>
			    <td valign=\"top\"><input type=\"text\" size=\"38\" name=\"no_sttp\" id=\"no_sttp\" value=\"".(isset($arr['no_sttp'])?$arr['no_sttp']:"")."\" /></td>
			  </tr>
			  <tr>
              	<td class='fieldname' valign=\"top\">Tanggal STTP</td>
		        <td valign=\"top\">:</td>
		        <td>".combo_tanggal('d_tgl_sttp',$d_tgl_sttp,'')."-".
        	          combo_bulan('m_tgl_sttp',$m_tgl_sttp,'').
        	          "-<input name='y_tgl_sttp' id='y_tgl_sttp' type='text' size='6' value='$y_tgl_sttp'/>
        		</td>
    		  </tr>
			  <tr>
			    <td valign=\"top\">&nbsp;</td>
			    <td valign=\"top\">&nbsp;</td>
			    <td valign=\"top\">
			      <input class=\"tombol\" type=\"button\" name=\"btn_kembali\" id=\"btn_kembali\" value=\"<< Kembali\" />
			      <input class=\"tombol\" type=\"submit\" name=\"button\" id=\"button\" value=\"   Simpan   \" />
			    </td>
			  </tr>
			</table>
			</fieldset>
			</form>
			  ";
        	
        	return $ret;
        }

        function simpan($arr, $is_update=false, $id='') {
            if (!$is_update) {
                $this->db->insert('diklat', $arr);
				//echo '<pre>'.print_r($arr,true)."</pre>".$id.$is_update;exit;
            } else {
                $this->db->where('idspg_diklat', $id);
                $this->db->update('diklat', $arr);
            }
        }
        
	}
?>